
<html>
<head>
<title>KAR Admin - New/Update Event</title>

<script language="JavaScript">
<!-- ;    This JS just checks to make sure something is entered in all fields.
function verifyIt() {
	var form = document.forms[0]
	for (i=0; i<form.elements.length; i++) {
		if (form.elements[i].value == "") {
			alert("Please fill out all fields.")
			form.elements[i].focus()
			return false
		}
	}
	return true
}
// end hide -->
</script>
</head>

<BODY BGCOLOR="#FFFFFF" TEXT="#000000" LINK="#0000FF" VLINK="#800080" ALINK="#800000">
<H2 align="left">KAR Internet Administration<br>
  Add/Update Event in Database</H2>
  <br>


<?php

include($_SERVER['DOCUMENT_ROOT'] ."/includes/db.php");

				// Connect to the database server
dbConnect('kar_web1');   	// Use function in db.php to connect


if (isset($update)) {
	$event_edit = @mysql_query("SELECT * FROM events WHERE eventID='$event'");
	if (!$event_edit) {
		echo("<p>Error performing query: " . mysql_error() . "</p>");
		 exit();
		} //  end if
	while ( $row = mysql_fetch_array($event_edit) ) {       // pull the record info on the event
		$temp_id = $row["eventID"];		// event id number
		$eventName = $row["eventName"];	// Name displayed to volunteers & public
		$eventDate = $row["eventDate"];
		list($eventyear, $eventmonth, $eventday) = explode("-", $eventDate); 
		$eventBeginTime = $row["eventBeginTime"];
		list($a_hour, $a_minute, $a_second) = explode(":", $eventBeginTime); 
		if ($a_hour >12) 
			{ $a_ampm='pm';
			  $a_hour = $a_hour-12;
			}
		   else
			{ $a_ampm='am';
			}

		$eventEndTime = $row["eventEndTime"];
		list($d_hour, $d_minute, $d_second) = explode(":", $eventEndTime); 
		if ($d_hour>12) 
			{ $d_ampm='pm';
			  $d_hour = $d_hour-12;
			}
		   else
			{ $d_ampm='am';
			}
		} // end while
	} // end if


?>

<!--  *************  FORM STARTS HERE  ********************  -->

<form action="event3.php<?php if (isset($update)) echo("?update=1");?>" method="post" onSubmit="return verifyIt()">

<?php if (isset($update)) echo("<input type=hidden name=\"eventID\" value=\"".$temp_id."\">") ?>

<TABLE border cellpadding="10">
<TR bgcolor="#ffcccc"><TD  valign=center align=middle >
<B>Event Name</B><BR></TD><TD>
<input type="text" size=50 name="eventName" value="<?php echo $eventName;?>">
</TD></TR>

<TR>
<TD  valign=center align=middle ><B>Event Date</B><BR></TD><TD>
<select NAME="eventmonth">
<option VALUE="01" <?php if ($eventmonth=='01') echo("SELECTED");?>>Jan
<option VALUE="02" <?php if ($eventmonth=='02') echo("SELECTED");?>>Feb
<option VALUE="03" <?php if ($eventmonth=='03') echo("SELECTED");?>>Mar
<option VALUE="04" <?php if ($eventmonth=='04') echo("SELECTED");?>>Apr
<option VALUE="05" <?php if ($eventmonth=='05') echo("SELECTED");?>>May
<option VALUE="06" <?php if ($eventmonth=='06') echo("SELECTED");?>>Jun
<option VALUE="07" <?php if ($eventmonth=='07') echo("SELECTED");?>>Jul
<option VALUE="08" <?php if ($eventmonth=='08') echo("SELECTED");?>>Aug
<option VALUE="09" <?php if ($eventmonth=='09') echo("SELECTED");?>>Sep
<option VALUE="10" <?php if ($eventmonth=='10') echo("SELECTED");?>>Oct
<option VALUE="11" <?php if ($eventmonth=='11') echo("SELECTED");?>>Nov
<option VALUE="12" <?php if ($eventmonth=='12') echo("SELECTED");?>>Dec
</select>&nbsp;&nbsp;
<select NAME="eventday">
<option VALUE="01" <?php if ($eventday=='01') echo("SELECTED");?>>1
<option VALUE="02" <?php if ($eventday=='02') echo("SELECTED");?>>2
<option VALUE="03" <?php if ($eventday=='03') echo("SELECTED");?>>3
<option VALUE="04" <?php if ($eventday=='04') echo("SELECTED");?>>4
<option VALUE="05" <?php if ($eventday=='05') echo("SELECTED");?>>5
<option VALUE="06" <?php if ($eventday=='06') echo("SELECTED");?>>6
<option VALUE="07"  <?php if ($eventday=='07') echo("SELECTED");?>>7
<option VALUE="08" <?php if ($eventday=='08') echo("SELECTED");?>>8
<option VALUE="09" <?php if ($eventday=='09') echo("SELECTED");?>>9
<option VALUE="10" <?php if ($eventday=='10') echo("SELECTED");?>>10
<option VALUE="11" <?php if ($eventday=='11') echo("SELECTED");?>>11
<option VALUE="12" <?php if ($eventday=='12') echo("SELECTED");?>>12
<option VALUE="13" <?php if ($eventday=='13') echo("SELECTED");?>>13
<option VALUE="14" <?php if ($eventday=='14') echo("SELECTED");?>>14
<option VALUE="15"<?php if ($eventday=='15') echo("SELECTED");?>>15
<option VALUE="16" <?php if ($eventday=='16') echo("SELECTED");?>>16
<option VALUE="17" <?php if ($eventday=='17') echo("SELECTED");?>>17
<option VALUE="18" <?php if ($eventday=='18') echo("SELECTED");?>>18
<option VALUE="19" <?php if ($eventday=='19') echo("SELECTED");?>>19
<option VALUE="20" <?php if ($eventday=='20') echo("SELECTED");?>>20
<option VALUE="21" <?php if ($eventday=='21') echo("SELECTED");?>>21
<option VALUE="22" <?php if ($eventday=='22') echo("SELECTED");?>>22
<option VALUE="23" <?php if ($eventday=='23') echo("SELECTED");?>>23
<option VALUE="24" <?php if ($eventday=='24') echo("SELECTED");?>>24
<option VALUE="25" <?php if ($eventday=='25') echo("SELECTED");?>>25
<option VALUE="26" <?php if ($eventday=='26') echo("SELECTED");?>>26
<option VALUE="27" <?php if ($eventday=='27') echo("SELECTED");?>>27
<option VALUE="28" <?php if ($eventday=='28') echo("SELECTED");?>>28
<option VALUE="29" <?php if ($eventday=='29') echo("SELECTED");?>>29
<option VALUE="30" <?php if ($eventday=='30') echo("SELECTED");?>>30
<option VALUE="31" <?php if ($eventday=='31') echo("SELECTED");?>>31
</select>&nbsp;&nbsp;
<select NAME="eventyear">
<option value="2008" selected <?php if ($eventyear=='2007') echo("SELECTED");?>>2008
<option value="2007" <?php if ($eventyear=='2007') echo("SELECTED");?>>2007
 <option value="2006" <?php if ($eventyear=='2006') echo("SELECTED");?>>2006
<option value="2005" <?php if ($eventyear=='2005') echo("SELECTED");?>>2005
 <option value="2004" <?php if ($eventyear=='2004') echo("SELECTED");?>>2004
</select></TD>
</TR>

<TR><TD><b>Start Time: <?php echo $a_hour;?></b></td><td>
<select NAME="a_hour">
    <option VALUE="1" <?php if ($a_hour=='1') echo("SELECTED");?>>1
    <option VALUE="2" <?php if ($a_hour=='2') echo("SELECTED");?>>2
    <option VALUE="3" <?php if ($a_hour=='3') echo("SELECTED");?>>3
    <option VALUE="4" <?php if ($a_hour=='4') echo("SELECTED");?>>4
    <option VALUE="5" <?php if ($a_hour=='5') echo("SELECTED");?>>5
    <option VALUE="6" <?php if ($a_hour=='6') echo("SELECTED");?>>6
    <option VALUE="7" <?php if ($a_hour=='7') echo("SELECTED");?>>7
    <option VALUE="8" <?php if ($a_hour=='8') echo("SELECTED");?>>8
    <option VALUE="9" <?php if ($a_hour=='9') echo("SELECTED");?>>9
    <option VALUE="10" <?php if ($a_hour=='10') echo("SELECTED");?>>10
    <option VALUE="11" <?php if ($a_hour=='11') echo("SELECTED");?>>11
    <option VALUE="12" <?php if ($a_hour=='12') echo("SELECTED");?>>12
    </select>
:    <select NAME="a_minute">
    <option VALUE="00" <?php if ($a_minute=='00') echo("SELECTED");?>>00
    <option VALUE="15" <?php if ($a_minute=='15') echo("SELECTED");?>>15
    <option VALUE="30" <?php if ($a_minute=='30') echo("SELECTED");?>>30
    <option VALUE="45" <?php if ($a_minute=='45') echo("SELECTED");?>>45
    </select>
    <select NAME="a_ampm">
    <option VALUE="am" <?php if ($a_ampm=='am') echo("SELECTED");?>>a.m.
    <option VALUE="pm" <?php if ($a_ampm=='pm') echo("SELECTED");?>>p.m.
  </select>
</td>
</tr> 
<tr><td><b>End Time:</b></td><td><select NAME="d_hour">
    <option VALUE="1" <?php if ($d_hour=='1') echo("SELECTED");?>>1
    <option VALUE="2" <?php if ($d_hour=='2') echo("SELECTED");?>>2
    <option VALUE="3" <?php if ($d_hour=='3') echo("SELECTED");?>>3
    <option VALUE="4" <?php if ($d_hour=='4') echo("SELECTED");?>>4
    <option VALUE="5" <?php if ($d_hour=='5') echo("SELECTED");?>>5
    <option VALUE="6" <?php if ($d_hour=='6') echo("SELECTED");?>>6
    <option VALUE="7" <?php if ($d_hour=='7') echo("SELECTED");?>>7
    <option VALUE="8" <?php if ($d_hour=='8') echo("SELECTED");?>>8
    <option VALUE="9" <?php if ($d_hour=='9') echo("SELECTED");?>>9
    <option VALUE="10" <?php if ($d_hour=='10') echo("SELECTED");?>>10
    <option VALUE="11" <?php if ($d_hour=='11') echo("SELECTED");?>>11
    <option VALUE="12" <?php if ($d_hour=='12') echo("SELECTED");?>>12
    </select>
:    <select NAME="d_minute">
    <option VALUE="00" <?php if ($d_minute=='00') echo("SELECTED");?>>00
    <option VALUE="15" <?php if ($d_minute=='15') echo("SELECTED");?>>15
    <option VALUE="30" <?php if ($d_minute=='30') echo("SELECTED");?>>30
    <option VALUE="45" <?php if ($d_minute=='45') echo("SELECTED");?>>45
    </select>
    <select NAME="d_ampm">
    <option VALUE="am" <?php if ($d_ampm=='am') echo("SELECTED");?>>a.m.
    <option VALUE="pm" <?php if ($d_ampm=='pm') echo("SELECTED");?>>p.m.
  </select>
</td></tr> 


</TABLE>


<BR><BR>
<CENTER>
<input type="submit" name="submitpet" value="SUBMIT EVENT"></p>
</CENTER>
</form>



</body>
</html>